﻿// EXP0513.cpp : 下面显示的每个程序都含有一个常见的编码错误，指出错误在哪里，然后修改它们。

//(a) unsigned aCnt = 0, eCnt = 0, iouCnt = 0;
//char ch = next_text();
//switch (ch) {
//case 'a': aCnt++;                     //缺少break;
//case 'e': eCnt++;                     //缺少break;
//default: iouCnt++;                    //缺少break;
//}
//(b) unsigned index = some_value();
//switch (index) {
//case 1:
//    int ix = get_value();
//    ivec[ix] = index;
//    break;
//default:
//    ix = ivec.size() - 1;             //ix缺少定义
//    ivec[ix] = index;//缺少break；
//}
//(c) unsigned evenCnt = 0, oddCnt = 0;
//int digit = get_num() % 10;
//switch (digit) {
//case 1, 3, 5, 7, 9:               //分支情况不用逗号串联
//    oddcnt++;
//    break;
//case 2, 4, 6, 8, 10:              //分支情况不用逗号串联
//    evencnt++;
//    break;
//}
//(d) unsigned ival = 512, jval = 1024, kval = 4096;
//unsigned bufsize;
//unsigned swt = get_bufCnt();
//switch (swt) {
//case ival:                        //分支情况不能用变量区别
//    bufsize = ival * sizeof(int);
//    break;
//case jval:                        //分支情况不能用变量区别
//    bufsize = jval * sizeof(int);
//    break;
//case kval:                        //分支情况不能用变量区别
//    bufsize = kval * sizeof(int);
//    break;
//}
//

//(a) unsigned aCnt = 0, eCnt = 0, iouCnt = 0;
//char ch = next_text();
//switch (ch) {
//case 'a':
//	aCnt++;
//	break;
//case 'e':
//	eCnt++;
//	break;
//default:
//	iouCnt++;
//	break;
//}
//
//
//(b) unsigned index = some_value();
//	int ix=0;
//switch (index) {
//case 1:
//    ix = get_value();
//    ivec[ix] = index;
//    break;
//default:
//    ix = ivec.size() - 1;
//    ivec[ix] = index;//缺少break；
//}
//(c) unsigned evenCnt = 0, oddCnt = 0;
//int digit = get_num() % 10;
//switch (digit) {
//case 1:
//case 3:
//case 5:
//case 7:
//case 9:
//    oddcnt++;
//    break;
//case 2:
//case 4:
//case 6:
//case 8:
//case 10:
//    evencnt++;
//    break;
//}
//(d) const unsigned ival = 512, jval = 1024, kval = 4096;
//unsigned bufsize;
//unsigned swt = get_bufCnt();
//switch (swt) {
//case ival:                        //分支情况不能用变量区别
//    bufsize = ival * sizeof(int);
//    break;
//case jval:                        //分支情况不能用变量区别
//    bufsize = jval * sizeof(int);
//    break;
//case kval:                        //分支情况不能用变量区别
//    bufsize = kval * sizeof(int);
//    break;
//}
//

